package com.studay;


public class Person {
    private int age;
    private String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }


    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    //析构函数
    //关于clear 因为
    protected void finalize() throws Throwable{
        super.finalize();
        //检测对象数组中的对象 是否被清除
        System.out.println("Person - finalize");
    }

    public boolean equals(Object obj){
        //重写equals 是为了更好比较这两个数据是否相等
        //比如这样写就是 name相等 那么这两个数据我就认为他是相等的
        //如果不重写 就
        Person per = (Person) obj;
        return this.name == per.name;
    }


}
